package ngames.com.sushitv.temp.Presenter;

import android.os.Handler;
import android.os.Message;

import ngames.com.sushitv.AppApplication;
import ngames.com.sushitv.temp.Interface.FollowingInterface;
import ngames.com.sushitv.temp.Interface.FollowingTaskInterface;
import ngames.com.sushitv.temp.Module.FollowingFactory;


/**
 * Created by edmond on 16-7-28.
 */
public class FollowingPresenter implements FollowingTaskInterface {
    private FollowingFactory followingFactory;
    private FollowingInterface view;
    private AppApplication application;

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case 0:
                    view.initingData();
                    view.initedData();
                    break;
                case 1:
                    view.moredData();
                    break;
                case 2:
                    view.refreshedData();
                    break;
            }
        }
    };

    public FollowingPresenter(FollowingFactory followingFactory, FollowingInterface view,AppApplication application){
        this.application = application;
        this.followingFactory = followingFactory;
        this.view = view;
    }

    @Override
    public void initData() {
        followingFactory.initData(application,view.getFollowingsList(),handler);
    }

    @Override
    public void moreData() {
        view.moreingData();
        followingFactory.moreData(application,view.getFollowingsList(),handler,view.getPage());
    }

    @Override
    public void refeshData() {
        view.refreshingData();
        followingFactory.refreshData(application,view.getFollowingsList(),handler);
    }
}
